package org.springblade.modules.admin.task;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springblade.modules.admin.service.UserWeixinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Date 15:23 2022/8/29
 * @Description {
 * <p>
 * }
 * @Author lsay
 **/
@Component
public class UserWxInfoUpdateJob {

	@Autowired
	private UserWeixinService userWeixinService;

	/**
	 * 每日凌晨两点更新用户是否关注公众号
	 */
	//@Scheduled(cron = "0 0 2 * * ?")
	@XxlJob(value = "Scheduled")
	public void updateUserSubscribe() {

		XxlJobHelper.handleSuccess("更新用户是否关注公众号-(updateUserSubscribe)-[执行]开始");
		try {
			userWeixinService.updateUserSubscribe();
			XxlJobHelper.handleSuccess("更新用户是否关注公众号-(updateUserSubscribe)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("更新用户是否关注公众号-(updateUserSubscribe)-[执行]失败" + e);

		}
	}

}
